using System;
using System.Collections.Generic;


namespace DataObjects
{
	[Serializable]
	public class Customer: IEquatable<Customer>
	{

		#region Private Members

		private string _customer_id; 
		private string _customer_name; 
		private string _person_represent; 
		private string _person_represent_national; 
		private string _person_represent_mobile; 
		private string _person_represent_email; 
		private string _person_contact; 
		private string _person_contact_national; 
		private string _person_contact_mobile; 
		private string _person_contact_email; 
		private string _address; 
		private string _phone_work; 
		private string _phone_extension; 
		private string _fax; 
		private string _tax_code; 
		private string _bank_account; 
		private string _bank_code; 
		private string _special_require; 
		private string _remark; 
		private string _kind_of_customer; 
		private bool? _is_provider; 
		private string _status; 		
		#endregion

		#region Constructor

		public Customer()
		{
			_customer_id = String.Empty; 
			_customer_name = String.Empty; 
			_person_represent = String.Empty; 
			_person_represent_national = String.Empty; 
			_person_represent_mobile = String.Empty; 
			_person_represent_email = String.Empty; 
			_person_contact = String.Empty; 
			_person_contact_national = String.Empty; 
			_person_contact_mobile = String.Empty; 
			_person_contact_email = String.Empty; 
			_address = String.Empty; 
			_phone_work = String.Empty; 
			_phone_extension = String.Empty; 
			_fax = String.Empty; 
			_tax_code = String.Empty; 
			_bank_account = String.Empty; 
			_bank_code = String.Empty; 
			_special_require = String.Empty; 
			_remark = String.Empty; 
			_kind_of_customer = String.Empty; 
			_is_provider = new bool?(); 
			_status = String.Empty; 
		}
		#endregion // End of Default ( Empty ) Class Constuctor

		#region Required Fields Only Constructor
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public Customer(
			string customer_id, 
			string customer_name)
			: this()
		{
			_customer_id = customer_id;
			_customer_name = customer_name;
			_person_represent = String.Empty;
			_person_represent_national = String.Empty;
			_person_represent_mobile = String.Empty;
			_person_represent_email = String.Empty;
			_person_contact = String.Empty;
			_person_contact_national = String.Empty;
			_person_contact_mobile = String.Empty;
			_person_contact_email = String.Empty;
			_address = String.Empty;
			_phone_work = String.Empty;
			_phone_extension = String.Empty;
			_fax = String.Empty;
			_tax_code = String.Empty;
			_bank_account = String.Empty;
			_bank_code = String.Empty;
			_special_require = String.Empty;
			_remark = String.Empty;
			_kind_of_customer = String.Empty;
			_is_provider = null;
			_status = String.Empty;
		}
		#endregion // End Constructor

		#region Public Properties
			
		public virtual string CustomerId
		{
			get
			{ 
				return _customer_id;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for CustomerId", value, "null");
				
				if(  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for CustomerId", value, value.ToString());
				
				_customer_id = value;
			}
		}
			
		public virtual string CustomerName
		{
			get
			{ 
				return _customer_name;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for CustomerName", value, "null");
				
				if(  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for CustomerName", value, value.ToString());
				
				_customer_name = value;
			}
		}
			
		public virtual string PersonRepresent
		{
			get
			{ 
				return _person_represent;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PersonRepresent", value, value.ToString());
				
				_person_represent = value;
			}
		}
			
		public virtual string PersonRepresentNational
		{
			get
			{ 
				return _person_represent_national;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for PersonRepresentNational", value, value.ToString());
				
				_person_represent_national = value;
			}
		}
			
		public virtual string PersonRepresentMobile
		{
			get
			{ 
				return _person_represent_mobile;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PersonRepresentMobile", value, value.ToString());
				
				_person_represent_mobile = value;
			}
		}
			
		public virtual string PersonRepresentEmail
		{
			get
			{ 
				return _person_represent_email;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PersonRepresentEmail", value, value.ToString());
				
				_person_represent_email = value;
			}
		}
			
		public virtual string PersonContact
		{
			get
			{ 
				return _person_contact;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PersonContact", value, value.ToString());
				
				_person_contact = value;
			}
		}
			
		public virtual string PersonContactNational
		{
			get
			{ 
				return _person_contact_national;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for PersonContactNational", value, value.ToString());
				
				_person_contact_national = value;
			}
		}
			
		public virtual string PersonContactMobile
		{
			get
			{ 
				return _person_contact_mobile;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PersonContactMobile", value, value.ToString());
				
				_person_contact_mobile = value;
			}
		}
			
		public virtual string PersonContactEmail
		{
			get
			{ 
				return _person_contact_email;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PersonContactEmail", value, value.ToString());
				
				_person_contact_email = value;
			}
		}
			
		public virtual string Address
		{
			get
			{ 
				return _address;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for Address", value, value.ToString());
				
				_address = value;
			}
		}
			
		public virtual string PhoneWork
		{
			get
			{ 
				return _phone_work;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PhoneWork", value, value.ToString());
				
				_phone_work = value;
			}
		}
			
		public virtual string PhoneExtension
		{
			get
			{ 
				return _phone_extension;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for PhoneExtension", value, value.ToString());
				
				_phone_extension = value;
			}
		}
			
		public virtual string Fax
		{
			get
			{ 
				return _fax;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Fax", value, value.ToString());
				
				_fax = value;
			}
		}
			
		public virtual string TaxCode
		{
			get
			{ 
				return _tax_code;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for TaxCode", value, value.ToString());
				
				_tax_code = value;
			}
		}
			
		public virtual string BankAccount
		{
			get
			{ 
				return _bank_account;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for BankAccount", value, value.ToString());
				
				_bank_account = value;
			}
		}
			
		public virtual string BankCode
		{
			get
			{ 
				return _bank_code;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for BankCode", value, value.ToString());
				
				_bank_code = value;
			}
		}
			
		public virtual string SpecialRequire
		{
			get
			{ 
				return _special_require;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for SpecialRequire", value, value.ToString());
				
				_special_require = value;
			}
		}
			
		public virtual string Remark
		{
			get
			{ 
				return _remark;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for Remark", value, value.ToString());
				
				_remark = value;
			}
		}
			
		public virtual string KindOfCustomer
		{
			get
			{ 
				return _kind_of_customer;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for KindOfCustomer", value, value.ToString());
				
				_kind_of_customer = value;
			}
		}
			
		public virtual bool? IsProvider
		{
			get
			{ 
				return _is_provider;
			}
			set
			{
				_is_provider = value;
			}

		}
			
		public virtual string Status
		{
			get
			{ 
				return _status;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for Status", value, value.ToString());
				
				_status = value;
			}
		}
			
				
		#endregion 

		#region Public Functions

		#endregion //Public Functions

		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			Customer castObj = (Customer)obj; 
			return ( castObj != null ) &&
				( this._customer_id == castObj.CustomerId );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 ^ hash ^ _customer_id.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region IEquatable members

		public bool Equals(Customer other)
		{
			if (other == this)
				return true;
		
			return ( other != null ) &&
				( this._customer_id == other.CustomerId );
				   
		}

		#endregion
		
	}
}
